package 每日一题;

public class 搜索二维矩阵2 {
    public boolean searchMatrix(int[][] matrix, int target) {
        int m = matrix.length;
        int n = matrix[0].length;
        int i = 0,j = n-1;
        while (i<m && j<n){
            if (matrix[i][j]<target){
                i++;
            }
            else if (matrix[i][j]>target){
                j--;
            }
            else
                return true;
        }
        return false;
    }
}
